/**
 * Created by mac on 2017/12/21.
 */
import {INCREMENT, DESCREMENT, RESET} from "../actions/counter"

//reducer 默认传入先前的state和action
// 这里收到对应的action 则 对应将进行相应的state 的改变
const counter = (state = {count: 0}, action) => {
    switch (action.type) {
        case INCREMENT:
            return Object.assign({}, state, {
                    count: state.count + 1
                }
            )
        case
        DESCREMENT:
            return Object.assign({}, state, {
                    count: state.count - 1
                }
            )
        case
        RESET:
            return Object.assign({}, state, {
                    count: 0
                }
            )
        default: {
            return state
        }
    }
}
export default counter